package com.example.zeon;

import android.os.Bundle;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class DBActivity extends ListActivity {
	
	static final String[] COUNTRIES = new String[]{
		  "Americian","Belize","China","Japan","Korean","Russian"
		};
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_db);
        ListAdapter la = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, COUNTRIES);
        setListAdapter(la);  
    }
    
    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {  
            Toast.makeText(this, "你单击了"+COUNTRIES[position], Toast.LENGTH_SHORT).show();
    }
            
    // 创建菜单(Menu键操作)
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        menu.add(0, 0, 0, "关于");
        menu.add(0, 1, 1, "退出");
        return super.onCreateOptionsMenu(menu);
    }
    
    // 菜单响应
    public boolean onOptionsItemSelected(MenuItem item) {
        super.onOptionsItemSelected(item);
        switch (item.getItemId()) {
        case 0:
            Toast.makeText(DBActivity.this, "ZeonDB 1.0 by junq", Toast.LENGTH_LONG).show();  
         break;      
        case 1:
        	//返回上级
            //this.finish();
        	//其他Activity退出程序这样调用就ok了
        	SysUtil mSysUtil= new SysUtil(DBActivity.this);
        	mSysUtil.exit();         	
        break;
        }
        return true;
    } 
}
